Getting a cryptic error on my simple Java program, comparing char[i] to a string.

Posted by Sergio Tapia on Stack Overflow See other posts from Stack Overflow or by Sergio Tapia
Published on 2010-05-11T04:28:17Z Indexed on 2010/05/11 4:34 UTC
Read the original article Hit count: 271

Filed under:
|
|
public static void ejemplosString(String palabra){
        char[] letras = palabra.toCharArray();
        int contadorVocales = 0;

        for (int i = 0; i < letras.length; i++) {            
            if (char[i] == 'a') {
                contadorVocales++;                
            }

            if (char[i] == "e") {
                contadorVocales++;                
            }

            if (char[i] == "i") {
                contadorVocales++;                
            }

            if (char[i] == "o") {
                contadorVocales++;                
            }

            if (char[i] == "u") {
                contadorVocales++;                
            }
        }
    }

Getting the error on every If statement. Any guidance?

© Stack Overflow or respective owner

Related posts about java

Related posts about beginner